package com.cn.domain;

import java.util.List;

public class PageBean {

	private int totalCount; 	//总记录数    ---->数据库查询
	private List list; 			//要展示页面的结果列表  ---->数据库查询
	private int totalPage;		//总页码数--->在该类中计算得到
	private int currentPage; 	//要展示页面的当前页码数     --->用户传入
	private int perCount=8;		//每页显示的数量 --->预定义
	
	public PageBean(int totalCount, String currentPage) {
		this.totalCount = totalCount;
		try {
			this.currentPage = Integer.parseInt(currentPage);
		} catch (Exception e) {
			this.currentPage = 1;
		}
		totalPage = (totalCount+perCount-1)/perCount;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getPerCount() {
		return perCount;
	}

	public void setPerCount(int perCount) {
		this.perCount = perCount;
	}
	public int getStart(){
		return (currentPage-1)*perCount;
	}
	//获得页面起始页码
	public int getBegin(){
		int begin = currentPage-5;
		if(begin<1){
			begin = 1;
		}
		return begin;
	}
	//获得页面结束页码
	public int getEnd(){
		int end = currentPage+4;
		if(end>totalPage){
			end = totalPage;
		}
		return end;
	}
}
